package com.sc.rest.controller;

import com.sc.common.pojo.CommonResult;
import com.sc.common.utils.ExceptionUtil;
import com.sc.pojo.TbContent;
import com.sc.rest.service.ContentService;
import com.sc.rest.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by sc on 2017/10/19.
 */
@Controller

public class ContentController {
    @Autowired
    private ContentService contentService;
    @Autowired
    private ManagerService managerService;
    @RequestMapping("/content/{cid}")
    @ResponseBody
    public CommonResult getList(@PathVariable("cid")Long cid){
        try {
            List<TbContent> list = contentService.getlist(cid);
            return CommonResult.ok(list);
        } catch (Exception e) {
            return CommonResult.build(500, ExceptionUtil.getStackTrace(e));
        }
    }
    @RequestMapping("/content/syc/{cid}")
    @ResponseBody
    public CommonResult sycContent(@PathVariable("cid")Long cid){
        try {
            return managerService.syncContent(cid);
        } catch (Exception e) {
            return CommonResult.build(500, ExceptionUtil.getStackTrace(e));
        }
    }
}
